Repository navigation
Revert #553 (WarmUpBlockProvider deferred thread start): hangs the sampling profiler on Windows - #555
Jarred-Sumner wants to merge 1 commit into
Conversation
…equests" (#553) Deferring the helper thread start to the 64th MarkedBlock request means WTF::Thread::create now runs from tryAllocateAlignedMemory on the mutator while user code is executing. On Windows that hangs @datadog/pprof (JSC SamplingProfiler via the v8::CpuProfiler shim): test/integration/datadog-pprof times out at 120 s on windows-x64 in every Bun CI run pinned past #553 (builds 109483, 109496, 109557) and passes with the same Bun tree pinned to #552 without #553 (build 109518). Revert until the thread start is moved off the allocation path and verified against that test on Windows.
|
Not reverting; Bun turns |
| // MarkedBlock::tryCreate is the only caller today and always asks for a block-shaped region. | ||
| // The guard keeps a future caller of some other size from being handed a block. | ||
| if (alignment == MarkedBlock::blockSize && size == MarkedBlock::blockSize && WarmUpBlockProvider::isEnabled() && WarmUpBlockProvider::isPastStartThreshold()) { | ||
| if (alignment == MarkedBlock::blockSize && size == MarkedBlock::blockSize && WarmUpBlockProvider::isEnabled()) { |
There was a problem hiding this comment.
🟣 Pre-existing: this revert moves the first helper-thread spawn back to VM bring-up, but Thread::create is still issued from tryAllocateAlignedMemory on the mutator every time the helper has idle-timed-out (10 s of no block requests) and a new block is needed, so a long-running profiled process on Windows can still hit the same sampler self-deadlock the PR is reverting to avoid. Fix: never spawn the helper from the allocator — restart it from a safepoint, or drop the idle timeout so the OS thread stays alive once created.
Extended reasoning...
After the supply is filled and block demand stops, AutomaticThread waits warmUpMarkedBlockIdleTimeout (default 10 s), WarmUpThread::shouldSleep() sees m_demandSinceIdleCheck clear, and the OS thread exits via stopForTimeout → threadIsStopping (m_hasUnderlyingThread=false, m_phase=Stopped, m_blocks freed). The next MarkedBlock request reaches line 264 → singleton().tryTake() finds the supply empty and phase≠StandingDown → m_condition->notifyOne() → AutomaticThreadCondition::notifyOne finds !hasUnderlyingThread() → AutomaticThread::start() → WTF::Thread::create(), all on the JS mutator inside the allocation slow path with user code on the stack. That is the exact call the PR description names as the Windows self-deadlock trigger when SamplingProfiler suspends the JS thread mid thread-creation. The base branch has this same restart path (plus the 64th-block path the revert removes), so this is an unfixed sibling of the bug being addressed rather than a regression; a steady-state heap easily goes 10 s without needing a fresh MarkedBlock, so the window is…
Verification: pre-existing — the idle-timeout restart path is untouched by this diff and exists identically on the base branch (and pre-#553), so merging makes nothing worse; the specific CI test the PR targets completes in well under 10 s and won't hit it. Mechanism verified: - FastMallocAlignedMemoryAllocator.cpp:123 — WarmUpThread is constructed with timeout… | pre-existing — the idle-timeout re-spawn path…
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
WalkthroughChangesThe warm-up allocator no longer waits for a request-count threshold. The related JSC option is removed. Eligible Warm-up allocator behavior
Comment |
Preview Builds
|
Reverts #553.
#553 defers constructing
WarmUpBlockProvider(anAutomaticThread) from VM bring-up to the 64th MarkedBlock request, soWTF::Thread::createnow runs lazily fromtryAllocateAlignedMemoryon the mutator while user code executes. On Windows this hangs@datadog/pprof, which drivesJSC::SamplingProfilerthrough Bun'sv8::CpuProfilershim (the sampler suspends the JS thread; suspending it mid thread-creation is the usual Windows self-deadlock).Evidence from Bun CI (oven-sh/bun#41190, the first PR pinned past #553):
test/integration/datadog-pprof/datadog-pprof.test.ts—TimeProfiler start/stop returns a populated profiletimes out at 120 s on windows x64 only, 3/3 runs (BuildKite 109483, 109496, 109557).autobuild-preview-pr-552-287d9c5f(i.e. Carry the AsyncLocalStorage frame in promise reactions and microtask arguments instead of an InternalFieldTuple #552 without [JSC] WarmUpBlockProvider: start the helper thread after 64 block requests, not the first #553): passes (BuildKite 109518, [do not merge] CI bisect: #41190 with WebKit minus oven-sh/WebKit#553 bun#41217).491b5cc, pre-[JSC] WarmUpBlockProvider: start the helper thread after 64 block requests, not the first #553).Suggested reland: keep creating the helper thread at bring-up and defer only the warming work to the threshold (or start the thread from a safepoint rather than the allocator), verified against that test on Windows.